# _*_ coding: utf-8 _*_
# @Author   : Wei Yue
# @Time     : 2023-05-01 11:53
# @Function : 载荷谱生成全流程
# 功能描述： 1、将cruise生成的spd和trq的标准表 转换成 二维图标，速度、转矩范围可选 间隔可调整 时间尺度可调整
#          2、将疲劳值通过公式进行转换，转换可分为两种方式
#          2.1 自定义间隔，自定义转矩和转速间隔进行转换

from cruiseAnalysis.generateLoadSpectrum import *
from motorCalibration.MotorModel import MotorModelCls
from motorCalibration.extendCruiseDeatilExcel import *
from cruiseAnalysis.loadSpectrumConstant import *
from cruiseAnalysis.profileEnum import profileEnum

if __name__ == '__main__':
    oem = profileEnum.GM.value
    # path填写文件夹路径
    path = dataPath + oem
    # 初始化文件夹目录结构
    dirInitialize(path)
    # # 初始化电机对象
    HP26 = MotorModelCls('excel/motorMapMP16.xlsx', 0.0133, 3, 0.1)
    HP26.loadInvEffMap('excel/INVmap.xlsx')
    # # 扩展cruise参数 包括拿到AC端数据
    extendCruiseDetail(HP26, path)
    # 扩展完毕后 导出总载荷谱
    exportVehicleLoadSpectrum(path, -295, 295, 10, -4950, 4950, 100, 0.1)
    exportDCLoadSpectrum(path, 10, 890, 20, -790, 790, 20, 0.1)
    exportACLoadSpectrum(path, -1175, 1175, 50, -490, 490, 20, 0.1)
    exportEMLoadSpectrum(path, -19750, 19750, 500, -415, 415, 10, 0.1)
    getTotalLoadSpectrum(path, pathDict[oem][:3], oem)
    #######统计#############################
    statisticLoadSpectrum(path)
    getTotalStatistic(path, pathDict[oem][:3])
    # 计算减速器载荷谱
    tranferToPoints(path, [-255, -200, -150, -100, -50, 50, 100, 150, 200, 255],
                    [3000, 6000, 9000, 12000, 15000, 18000, 20000], [3, 6.611, 8.738])
    # 加速到500h左右
    # tranferToPoints(path, [-400, -200,  200, 400],
    #                 [5000, 10000, 15000, 20000], [3, 6.611, 8.738])
